function img = getimg( img, map, alpha )

img_sz = size(img);
assert(isa(img, 'uint8'), 'Unsupported image data type');
assert((img_sz(1) == 32 || img_sz(1) == 64) && img_sz(2) == 64, 'Invalid image size');
if isempty(map)
    if img_sz(3) < 4
        if isempty(alpha)
            img(:,:,4) = 255;
        else
            img(:,:,4) = alpha;
        end
    end
else
    tmp = ind2rgb(img, map);
    tmp(:,:,4) = logical(img);
    img = uint8(tmp * 255);
end
if img_sz(1) == 32
    img(33:64,:,:) = 0;
    img(49:52,21:24,:) = img(17:20,8:-1:5,:);
    img(49:52,25:28,:) = img(17:20,12:-1:9,:);
    img(53:64,25:28,:) = img(21:32,4:-1:1,:);
    img(53:64,21:24,:) = img(21:32,8:-1:5,:);
    img(53:64,17:20,:) = img(21:32,12:-1:9,:);
    img(53:64,29:32,:) = img(21:32,16:-1:13,:);
    img(49:52,37:40,:) = img(17:20,48:-1:45,:);
    img(49:52,41:44,:) = img(17:20,52:-1:49,:);
    img(53:64,41:44,:) = img(21:32,44:-1:41,:);
    img(53:64,37:40,:) = img(21:32,48:-1:45,:);
    img(53:64,33:36,:) = img(21:32,52:-1:49,:);
    img(53:64,45:48,:) = img(21:32,56:-1:53,:);
end
img(1:16,1:32,4) = 255;
if img_sz(1) == 32 && isempty(find(img(1:32,33:64,4) < 128, 1))
    img(1:32,33:64,4) = 0;
end
img(17:32,1:64,4) = 255;
img(49:64,17:48,4) = 255;